<?php
namespace app\business\controller;
use app\business\model\BusinessClassify;
use app\business\model\BusinessLogin;
use think\Controller;
use app\business\controller\Base;
use think\Db;
use think\Session;

class Cashorder extends Base
{
    public function index()
    {
        $username = Session::get('username');

        $count = BusinessLogin::where('username',$username)->find();

        $num=$count['business_id'];

        $data = Db::table('business_cash_get')->where('business_id',$num)->select();

        $this->assign('data',$data);

        return $this->fetch();
    }

    //撤销当前本次提现申请
    public function changeStatus($id)
    {
        $demo = Db::table('business_cash_get')->where('id',$id)->find();

        $username = Session::get('username');

        $count = BusinessLogin::where('username',$username)->find();

        $num=$count['business_id'];

        $action = Db::table('business_cash')->where('business_id',$num)->find();

        $money = $demo['cash_money']+$action['cash_num'];

        Db::table('business_cash')->where('business_id',$num)->update(['cash_num'=>$money]);

        Db::table('business_cash_get')->where('id',$id)->update(['cash_status'=>3]);

        return $this->redirect('index');
    }
}